<template>
  <div class="app-container calendar-list-container">
    <div class="apply-query">
      <el-row class="filter-query" style="position: relative">
        <el-col><span>{{$t('scheduleManager.progressList.queryCondition')}}</span></el-col> <!--查询条件-->
      </el-row>
      <popover-set-query @clickShow="clickShow">
        <el-form :inline="true" :model="listQuery" style="padding: 0 20px" :class="{'show':!showI}">
          <el-row style="padding-bottom: 10px">
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.systemType')}}</div> <!--系统别-->
                <dict-select v-model="listQuery.systemType" code="systemType" @change="aaa"></dict-select>
              </div>
            </el-col>
<!--            <el-col :span="4">-->
<!--              <div class="w20">-->
<!--                <div class="labelName">{{$t('scheduleManager.progressList.companyType')}}</div> &lt;!&ndash;公司别&ndash;&gt;-->
<!--                <el-select v-model="listQuery.companyType" multiple collapse-tags :placeholder="$t('scheduleManager.progressList.commonSelectPlaceholder')"> &lt;!&ndash;请选择&ndash;&gt;-->
<!--                  <el-option v-for="item in this.$store.getters.allDic.company" :key="item.value" :label="item.label" :value="item.value"></el-option>-->
<!--                </el-select>-->
<!--              </div>-->
<!--            </el-col>-->
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('specialApplication.maintenance.country')}}</div>
                <dict-select v-model="listQuery.country" code="country" :clearable="true" @change="setBg"></dict-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">Account</div>
                <el-select multiple collapse-tags clearable v-model="listQuery.buLists"  :placeholder="$t('placeholder.choose')">
                  <el-option v-for="item in buList" :key="item" :label="item" :value="item"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">成案否</div>
                <el-select clearable v-model="listQuery.isCase"  :placeholder="$t('placeholder.choose')">
                  <el-option v-for="item in NorY" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.projectStatus')}}</div> <!--专案状态-->
                <el-select v-model="listQuery.projectStatus" multiple collapse-tags :placeholder="$t('scheduleManager.progressList.commonSelectPlaceholder')"> <!--请选择-->
                  <el-option v-for="item in this.$store.getters.allDic.projectStatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.epcType')}}</div> <!--工程类别-->
                <el-select v-model="listQuery.epcType" multiple collapse-tags :placeholder="$t('scheduleManager.progressList.commonSelectPlaceholder')"> <!--请选择-->
                  <el-option v-for="item in epcType" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.projectNo')}}</div> <!--专案编号-->
                <el-select v-model="listQuery.projectNo" multiple filterable remote reserve-keyword collapse-tags :placeholder="$t('scheduleManager.progressList.selectProjectNoPlaceholder')" :remote-method="getUserList" :loading="loading" :no-data-text="$t('public.noData')" :loading-text="$t('public.loading')"> <!--请输入专案编号关键词-->
                  <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.label"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.systemNo')}}</div> <!--系统编号-->
                <el-input v-model="listQuery.systemNo" :placeholder="$t('scheduleManager.progressList.systemNo')" clearable class="filter-item"></el-input><!--请输入系统编号-->
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.projectYear')}}</div> <!--专案年度-->
                <el-select v-model="listQuery.projectYear" multiple collapse-tags :placeholder="$t('scheduleManager.progressList.commonSelectPlaceholder')"> <!--请选择-->
                  <el-option v-for="item in this.$store.getters.allDic.year" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.constomerShortName')}}</div> <!--客户简称-->
                <el-select v-model="listQuery.customerName" filterable clearable remote reserve-keyword collapse-tags :placeholder="$t('scheduleManager.progressList.constomerSelectPlaceholder')" :remote-method="queryCustomer" :loading="loading"  :no-data-text="$t('public.noData')" :loading-text="$t('public.loading')"> <!--请输入客户简称-->
                  <el-option v-for="item in optionsCustomer" :key="item.value" :label="item.label" :value="item.label"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.PONO')}}</div> <!--PO单号-->
                <div style="display: flex">
                  <dict-select :class="{'wid':listQuery.hasPoNo === '1'}" v-model="listQuery.hasPoNo" code="practicalFinishDate" :clearable="true"></dict-select>
                  <el-input v-if="listQuery.hasPoNo === '1'" v-model="listQuery.poNo" :placeholder="$t('scheduleManager.progressList.commonEnterPlaceHolder')" clearable class="filter-item"></el-input> <!--请输入-->
                </div>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">專案業務/專案工程師</div> <!--專案業務/專案工程師-->
                <popover-select selectType="user" @input="setSignersignatory" v-model="listQuery.peopleName" :placeholder="$t('travelManagement.travelApplicationDetails.tips.employUserId')"></popover-select>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.actualFinishDate')}}</div> <!--实际完工日期-->
                <div style="display: flex">
                  <dict-select :class="{'wid':listQuery.hasRealityFinishDate === '1'}" v-model="listQuery.hasRealityFinishDate" code="practicalFinishDate" :clearable="true"></dict-select>
                  <div class="block" v-if="listQuery.hasRealityFinishDate === '1'">
                    <el-date-picker style="width:100%;" v-model="listQuery.realityFinishDate" type="date" :value-format="format" :format="format" :placeholder="$t('scheduleManager.progressList.selectDatePlaceHolder')"></el-date-picker> <!--选择日期-->
                  </div>
                </div>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.writeInvoiceDate')}}</div> <!--开发票日期-->
                <div style="display: flex">
                  <dict-select :class="{'wid':listQuery.hasInvoiceDate === '1'}" v-model="listQuery.hasInvoiceDate" code="practicalFinishDate" :clearable="true"></dict-select>
                  <div class="block" v-if="listQuery.hasInvoiceDate === '1'">
                    <el-date-picker style="width:100%;" v-model="listQuery.invoiceDate" type="date" :value-format="format" :format="format" :placeholder="$t('scheduleManager.progressList.selectDatePlaceHolder')"></el-date-picker> <!--选择日期-->
                  </div>
                </div>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.ERPReceiveNo')}}</div> <!--ERP应收单号-->
                <el-input v-model="listQuery.erpReceivablesNo" :placeholder="$t('scheduleManager.progressList.enterERPNOPlaceholder')" clearable class="filter-item"></el-input><!--请输入ERP应收单号-->
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.realityReceivablesDate')}}</div> <!--实际收款日-->
                <div style="display: flex">
                  <dict-select :class="{'wid':listQuery.hasRealityReceivablesDate === '1'}" v-model="listQuery.hasRealityReceivablesDate" code="practicalFinishDate" :clearable="true"></dict-select>
                  <div class="block" v-if="listQuery.hasRealityReceivablesDate === '1'">
                    <el-date-picker style="width:100%;" v-model="listQuery.realityReceivablesDate" type="date" :value-format="format" :format="format" :placeholder="$t('scheduleManager.progressList.selectDatePlaceHolder')"></el-date-picker> <!--选择日期-->
                  </div>
                </div>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.vendorShortName')}}</div><!--厂商简称-->
                <popover-select selectType="vendor" :placeholder="$t('scheduleManager.worksDetails.vendorPlaceholder')" valueObjName="vendorShortName" v-model="listQuery.vendorName"></popover-select>
              </div>
            </el-col>
            <!-- 2021-11-18 添加存档编号查询条件-->
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.fileNo')}}</div><!--存档编号-->
                <el-input v-model="listQuery.fileNo" :placeholder="$t('scheduleManager.progressList.eneterFileNoPlaceholder')" clearable class="filter-item"></el-input><!--请输入存档编号-->
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.vendorPoNO')}}</div><!--厂商PO单号-->
                <el-input v-model="listQuery.vendorPoNo" :placeholder="$t('scheduleManager.progressList.eneterVendorPoNoPlaceholder')" clearable class="filter-item"></el-input><!--请输入厂商PO单号-->
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.ERPPaymentNo')}}</div><!--ERP应付单号-->
                <el-input v-model="listQuery.erpPayableNo" :placeholder="$t('scheduleManager.progressList.eneterERPPaymentNoPlaceholder')" clearable class="filter-item"></el-input><!--请输入ERP应付单号-->
              </div>
            </el-col>
            <el-col :span="4">
              <div class="w20">
                <div class="labelName">{{$t('scheduleManager.progressList.vendorInvoiceDate')}}</div> <!--厂商发票日期-->
                <div style="display: flex">
                  <dict-select :class="{'wid':listQuery.hasVendorInvoiceDate === '1'}" v-model="listQuery.hasVendorInvoiceDate" code="practicalFinishDate" :clearable="true"></dict-select>
                  <div class="block" v-if="listQuery.hasVendorInvoiceDate === '1'">
                    <el-date-picker style="width:100%;" v-model="listQuery.vendorInvoiceDate" type="date" :value-format="format" :format="format" :placeholder="$t('scheduleManager.progressList.selectDatePlaceHolder')"></el-date-picker> <!--选择日期-->
                  </div>
                </div>
              </div>
            </el-col>
            <el-col :span="8" style="margin-top: 32px">
              <div class="yt-btn yt-btn-ys" style="margin-right: 12px" @click="handleFilter">{{$t('scheduleManager.progressList.query')}}</div> <!--查询-->
              <div class="yt-btn" @click="reset">{{$t('scheduleManager.progressList.reset')}}</div> <!--/重置-->
            </el-col>
          </el-row>
        </el-form>
      </popover-set-query>
    </div>

    <div class="data-list" v-loading="!show" :element-loading-text="$t('scheduleManager.progressList.loading')" element-loading-spinner="el-icon-loading"><!--拼命加载中-->
      <el-row class="list-content">
        <el-col><span>{{$t('scheduleManager.progressList.workList')}}</span></el-col> <!--工务列表-->
      </el-row>
      <div class="list-operation" style="padding-bottom: 0">
        <div style="margin-bottom: 10px">
          <el-button type="primary" class="yt-btn-ys" @click="add">{{$t('scheduleManager.progressList.add')}}</el-button> <!--新增-->
          <!--<el-button type="primary" class="yt-btn" @click="redact">{{$t('scheduleManager.progressList.update')}}</el-button> &lt;!&ndash;/修改&ndash;&gt;-->
            <!--删除-->
          <div class="yt-btn yt-ml8" type="danger" v-if="demandDeltePermision" @click="handleDelete('del')">{{$t('button.delete')}}</div>
          <el-button type="primary" class="yt-btn" @click="handleRemit">{{$t('scheduleManager.progressList.download')}}</el-button> <!--汇出-->
          <el-button type="primary" @click="downloadProgressFile('0')" class="yt-btn">{{$t('scheduleManager.progressList.workFinishDownload')}}</el-button><!--完工证明下载-->
          <el-button type="primary" @click="downloadProgressFile('1')" class="yt-btn">{{$t('scheduleManager.progressList.constomerSatisfactionDownload')}}</el-button><!--客户满意度下载-->
          <el-button type="primary" @click="downloadProgressFile('2')" class="yt-btn">{{$t('scheduleManager.progressList.vendorTableDownload')}}</el-button><!--厂商评鉴表下载-->
          <el-button type="primary" class="yt-btn" @click="quotedPrice">{{$t('scheduleManager.progressList.callPrice')}}</el-button><!--报价-->
          <el-button type="primary" class="yt-btn" @click="setProportion = true">{{$t('scheduleManager.progressList.isShow')}}</el-button><!--栏位显示/隐藏-->
          <!-- <el-button type="primary" class="yt-btn" @click="lead">{{$t('scheduleManager.progressList.lead')}}</el-button>  -->
        </div>
        <div>
          <el-table v-if="show" :data="list" :empty-text="$t('placeholder.emptyText')" border class="yt-table" max-height="600" @selection-change="handleSelectionChange" @sort-change="sortDate" @row-click="handlePreserve">
            <el-table-column label="Sum" align="center" width="120" fixed>
              <el-table-column type="selection" align="center" prop="id" width="60"></el-table-column>
              <el-table-column type="index" align="center" :label="$t('scheduleManager.progressList.number')" width="60"></el-table-column><!--序号-->
            </el-table-column>
            <el-table-column v-for="(col,i) in blockList" :key="col.label" align="center" :label="col.sum ? col.sum + '' : ''" :min-width="col.blockCode.match(/projectName|epcContent|vendorItem/) ? 200 : 120" :fixed="col.blockCode.match(/projectName|projectNo/) ? true : false">
              <el-table-column :prop="col.blockCode" :label="col.label" sortable="custom" align="center" :min-width="col.blockCode.match(/projectName|epcContent|vendorItem/) ? 200 : 120" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-if="col.blockCode.match(/projectYear|offerYear|executeYear|customerYear/)">{{ scope.row[col.blockCode] }}</span>
                  <!--專案進度會議(次期)-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'progressMeetingAnother'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.progressMeetingAnotherIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--結案會議-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'endCaseMeeting'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.endCaseMeetingIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--完工證明上傳-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'completionCertificateFile'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.completionCertificateFileIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--顧客滿意度調查-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'satisfactionSurveyFile'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.satisfactionSurveyFileIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--保險日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'insureDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.insureDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--複驗日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'reinspectionDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.reinspectionDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--客戶保固開始日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'warrantyStartDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.warrantyStartDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--客戶保固截止日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'warrantyEndDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.warrantyEndDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--客戶保固金領回日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'warrantyReceiveDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.warrantyReceiveDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--異常查修日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'anomalyCheckDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.anomalyCheckDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <!--異常報告提交日-->
                  <span style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" v-else-if="col.blockCode === 'anomalyReportDate'"> <!--|endCaseMeeting/)-->
                    <span v-if="scope.row.anomalyReportDateIs !== '1'">{{ scope.row[col.blockCode] }}</span>
                    <span v-else>N/A</span>
                  </span>
                  <span v-else v-format="typeof(scope.row[col.blockCode]) !== 'string'  ? '#,##0' : '0'" style="overflow: hidden;text-overflow: ellipsis;cursor: pointer;" >{{ scope.row[col.blockCode] }}</span>
                </template>
              </el-table-column>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div class="pagination-container" style="margin-top: 0">
        <el-pagination @current-change="handleCurrentChange" @size-change="handleSizeChange" background :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50, 100, 200]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
      </div>
    </div>
    <el-dialog :title="$t('scheduleManager.progressList.setShow')" :visible.sync="setProportion"> <!--设置可顯示欄位-->
      <el-checkbox v-model="checkAll" @change="handleCheckAllChange">{{$t('scheduleManager.progressList.allSelect')}}</el-checkbox><!--全选-->
      <div style="margin: 15px 0;"></div>
      <el-checkbox-group v-model="displayBlockName" @change="handleCheckedCitiesChange">
        <el-checkbox v-for="block in templateBlock" :label="block.blockCode" :key="block.id">{{block.label}}</el-checkbox>
      </el-checkbox-group>
      <span slot="footer" class="dialog-footer">
        <el-button class="yt-btn" @click="setProportion = false">{{$t('scheduleManager.progressList.cancel')}}</el-button><!--取 消-->
        <el-button class="yt-btn-ys" type="primary" @click="saveDisplayBlock">{{$t('scheduleManager.progressList.sure')}}</el-button><!--确 定-->
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import popoverSelect from '@/components/popover-select/index.vue';
  import popoverSetQuery from '@/components/popover-setQuery/index.vue';
  import { queryBySystemType, queryList, queryDisplayBlock, saveDisplayBlock, projectProgressDelete } from '@/api/scheduleManager/progressList';
  import { queryProject } from '@/api/scheduleManager/worksDetails';
  import customerReq from '@/api/customer';
  import { selectBuDataPermissions, getDeptByBuAndCountry } from '@/api/bu/index';

  import formatter from '@/utils/formatter';
  export default {
    name: 'progressList',
    components: {
      popoverSelect,
      popoverSetQuery,
      'dict-select': () => import('@/components/Dict/dictValueSelect'),
      'yt-select': () => import('@/components/Yt-select/index')
    },
    data() {
      return {
        NorY: this.$store.getters.allDic.NorY,
        show: false,
        showI: true,
        listMapAll: this.$store.getters.allMapDic,
        demandDeltePermision: false, // 是否有删除权限
        format: 'yyyy-MM-dd', // 时间格式
        total: 0,
        subtotal: {},
        epcType: this.$store.getters.allDic.epcType,
        listQuery: {
          isCase: '',
          peopleName: '',
          peopleId: '',
          buLists: [],
          isTodo: '1', // 是否按待办progressids查询
          page: 1,
          limit: 10,
          companyType: [], // 公司别
          projectStatus: [], // 工程狀態
          systemType: '', // 系統別
          epcType: [], // 工程類別
          vendorPoNo: '', // PO单号
          poNo: '', // SO单号
          hasPoNo: '', // so单号是否有值,0无值,1有值
          projectNo: [], // 专案编号
          projectYear: [], // 專案年度
          customerName: '', // 客戶簡稱
          erpReceivablesNo: '', // ERP應收單號
          erpPayableNo: '', // ERP應付單號
          vendorName: '', // 廠商簡稱
          hasRealityFinishDate: '', // 是否有实际完工日期,0无值,1有值
          realityFinishDate: '', // 实际完工日期
          hasInvoiceDate: '', // 是否有开发票日期,0无值,1有值
          invoiceDate: '', // 开发票日期
          vendorInvoiceDate: '', // 厂商发票日期
          hasVendorInvoiceDate: '', // 是否有厂商发票日期,0无值,1有值
          hasRealityReceivablesDate: '', // 是否有实际收款日期,0无值,1有值
          realityReceivablesDate: '' // 实际收款日期
        },
        loading: false,
        options: [],
        optionsCustomer: [],
        formatter,
        blockList: [],
        blockName: {},
        sumBlock: [],
        templateBlock: [],
        displayBlock: [],
        displayBlockName: [],
        // 所有标题
        list: [],
        selectionList: [],
        setProportion: false,
        checkAll: false,
        checkedCities: [],
        cities: [],
        buList: [],
        isIndeterminate: true
      };
    },
    computed: {

    },
    watch: {
      'listQuery.systemType'(val) {
        this.getBlock();
        this.epcType = this.$store.getters.allDic.epcType.filter(item => item.remark.indexOf(val) !== -1)
        // this.listQuery.epcType = []
      },
      'listQuery.peopleName'(val) {
        if (!val) {
          this.listQuery.peopleId = ''
        }
      }
    },
    created() {
       console.log('d3f546a991b74261b180834e42ae32e4', this.$store.getters.info.groupType)
      if('d3f546a991b74261b180834e42ae32e4'=== this.$store.getters.info.groupType){
          this.demandDeltePermision = true; 
      }
      this.blockName = this.$store.getters.allMapDic.nameColumn
      this.getBu()
      this.getQuery()
      this.initData()
    },
    methods: {
      setBg(country) {
        const param = {}
        if (country) {
          param.country = country
          param.bu = []
          param.bg = []
          getDeptByBuAndCountry(param).then(res => {
            this.buList = res.data.buList;
          })
        }
      },
      setSignersignatory(val, item) {
        this.listQuery.peopleId = item.id
        this.listQuery.peopleName = item.ename
      },
      getBu() {
        selectBuDataPermissions().then(res => {
          this.buList = res.data;
        });
      },
      aaa() {
        this.listQuery.epcType = []
      },
      getQuery() {
        const progressListQuery = window.sessionStorage.getItem('progressListQuery');
        if (progressListQuery) {
          this.listQuery = JSON.parse(progressListQuery);
        }
        if (this.$route.query.isTodo) { // 说明就是从首页过来的，那么之前的保存的条件无效
          this.listQuery = {
            isCase: '',
            peopleName: '',
            peopleId: '',
            buLists: [],
            isTodo: '1', // 是否按待办progressids查询
            page: 1,
            limit: 10,
            companyType: [], // 公司别
            projectStatus: [], // 工程狀態
            systemType: '', // 系統別
            epcType: [], // 工程類別
            vendorPoNo: '', // PO单号
            poNo: '', // SO单号
            hasPoNo: '', // so单号是否有值,0无值,1有值
            projectNo: [], // 专案编号
            projectYear: [], // 專案年度
            customerName: '', // 客戶簡稱
            erpReceivablesNo: '', // ERP應收單號
            erpPayableNo: '', // ERP應付單號
            vendorName: '', // 廠商簡稱
            hasRealityFinishDate: '', // 是否有实际完工日期,0无值,1有值
            realityFinishDate: '', // 实际完工日期
            hasInvoiceDate: '', // 是否有开发票日期,0无值,1有值
            invoiceDate: '', // 开发票日期
            vendorInvoiceDate: '', // 厂商发票日期
            hasVendorInvoiceDate: '', // 是否有厂商发票日期,0无值,1有值
            hasRealityReceivablesDate: '', // 是否有实际收款日期,0无值,1有值
            realityReceivablesDate: '' // 实际收款日期
          }
        }
      },
      clickShow(val) {
        this.showI = val
      },
      getUserList(query) {
        this.loading = true;
        queryProject({ projectNo: query }).then(res => {
          this.loading = false;
          this.options = res.data.rows.map(item => ({ value: item.id, label: item.projectNo }));
        });
      },
      queryCustomer(query) {
        this.loading = true;
        customerReq.pageClient({ clientName: query }).then(res => {
          this.loading = false;
          this.optionsCustomer = res.data.rows.map(item => ({ value: item.id, label: item.customerShortName }));
        });
      },
      handleSizeChange(val) {
        this.listQuery.limit = val;
        this.getData();
      },
      handleCurrentChange(val) {
        this.listQuery.page = val;
        this.getData();
      },
      // 查询
      handleFilter() {
        // 清楚默认查询的待办记录
        this.listQuery.isTodo = '0'
        this.getData()
      },
      // 重置
      reset() {
        this.listQuery = {
          isCase: '',
          peopleName: '',
          peopleId: '',
          buLists: [],
          companyType: [], // 公司别
          projectStatus: [], // 工程狀態
          systemType: '', // 系統別
          epcType: [], // 工程類別,
          fileNo: '', // 存档编号
          vendorPoNo: '', // 厂商的PO单号
          poNo: '', // SO单号
          hasPoNo: '', // so单号是否有值,0无值,1有值
          projectNo: [], // 专案编号
          projectYear: [], // 專案年度
          customerName: '', // 客戶簡稱
          erpReceivablesNo: '', // ERP應收單號
          erpPayableNo: '', // ERP應付單號
          vendorName: '', // 廠商簡稱
          hasRealityFinishDate: '', // 是否有实际完工日期,0无值,1有值
          realityFinishDate: '', // 实际完工日期
          hasInvoiceDate: '', // 是否有开发票日期,0无值,1有值
          invoiceDate: '', // 开发票日期
          vendorInvoiceDate: '', // 厂商发票日期
          hasVendorInvoiceDate: '', // 是否有厂商发票日期,0无值,1有值
          hasRealityReceivablesDate: '', // 是否有实际收款日期,0无值,1有值
          realityReceivablesDate: '', // 实际收款日期
          limit: 10,
          page: 1
        }
        this.getData()
      },
      saveDisplayBlock() {
        const obj = {
          userId: this.$store.getters.info.id,
          systemType: this.listQuery.systemType === '' ? 'A' : this.listQuery.systemType,
          codeList: this.displayBlockName
        }
        saveDisplayBlock(obj).then(() => {
          this.setProportion = false
          this.getBlock()
        })
      },
      handleSelectionChange(val) {
        //  表格序号选中函数
        this.selectionList = val;
      },
      // 排序
      sortDate(column) {
        // if (column.order) {
        //   this.formatter.sortByKey(this.list, column.prop, column.order)
        // }
        if (column.order === 'ascending') {
          this.listQuery.order = 'asc';
        } else if (column.order === 'descending') {
          this.listQuery.order = 'desc';
        }
        this.listQuery.orderBy = column.prop;
        this.getData()
      },
      //导入
      lead(){
        this.$router.push({ path: '/progressManager/lead' })
      },
      // 新增
      add() {
        this.$router.push({ path: '/progressManager/worksDetails' })
      },
      // 编辑
      redact() {
        const list = [];
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.selectionList.length <= 0 ? this.$t('scheduleManager.progressList.updateTipsOne') : this.$t('scheduleManager.progressList.updateTipsTwo'), // '您还未选择' : '您只能选择一条数据进行编辑修改'
            type: 'warning'
          });
          return;
        }
        this.selectionList.forEach(key => {
          list.push(key.id);
        });
        this.$router.push({ path: '/progressManager/worksDetails', query: { progressId: this.selectionList[0].id } })
      },
      handlePreserve(row, event, column) {
        if (column.property !== 'id') {
          this.$router.push({ path: '/progressManager/worksDetails', query: { progressId: row.id } })
        }
      },
      downloadProgressFile(type) {
        const list = [];
        console.log('this.selectionList', this.selectionList, this.selectionList.length)
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.$t('scheduleManager.progressList.noSelectTips'), // '您还未选择',
            type: 'warning'
          });
          return;
        }
        this.selectionList.forEach(key => {
          if (type === '0') {
            // 判断是否有完工证明
            if (key.completionCertificateFile) {
              list.push(key.id);
            }
          } else if (type === '1') {
            // 判断是否有顧客滿意度調查
            if (key.satisfactionSurveyFile) {
              list.push(key.id);
            }
          } else if (type === '2') {
            if (key.vendorAppraiseDate) {
              list.push(key.id);
            }
            if (key.projectWorkUpload) {
              list.push(key.id);
            }
          }
        });

        if (list.length === 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.$t('scheduleManager.progressList.noUploadTips'), // 您还未上传文件
            type: 'warning'
          });
          return;
        }

        let str = ''; // 传参数
        str = 'ids=' + list + '&type=' + type + '&createBy=' + this.$store.getters.info.id;
        // str = 'type=' + type;

        const a = document.createElement('a');
        const href = '/api/admin/excel/downloadProgressFile?' + str;
        a.download = Date.now();
        a.href = href;
        a.click();
      },
      // 汇出
      handleRemit() {
        let str = ''; // 传参数
        const query = this.listQuery
        for (const i in query) {
          if (query[i]) {
            str += i + '=' + query[i] + '&';
          }
        }

        if (this.$store.getters.info && this.$store.getters.info.id) {
          str = str + 'createBy=' + this.$store.getters.info.id;
        }

        const a = document.createElement('a');
        const href = '/api/admin/excel/excelProjectProgress?' + str;
        a.download = Date.now();
        a.href = href;
        a.click();
      },
      // 报价
      quotedPrice() {
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.selectionList.length <= 0 ? this.$t('scheduleManager.progressList.updateTipsOne') : this.$t('scheduleManager.progressList.updateTipsTwo'), // '您还未选择' : '您只能选择一条数据进行编辑修改',
            type: 'warning'
          });
          return;
        }
        this.$router.push({ path: '/progressManager/businessManager', query: { title: 'update', id: this.selectionList[0].id } });
        window.sessionStorage.setItem('progressListDetail', JSON.stringify(this.selectionList[0]))
      },
      // 全选
      handleCheckAllChange(val) {
        const list = []
        if (val) {
          this.templateBlock.forEach(key => {
            list.push(key.blockCode)
          })
        }
        this.displayBlockName = val ? list : [];
        this.isIndeterminate = false;
      },
      handleCheckedCitiesChange(value) {
        const checkedCount = value.length;
        // 全选
        this.checkAll = checkedCount === this.templateBlock.length;
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.templateBlock.length;
      },
      sisExistArr(arr1, arr2, new_arr) {
        // arr1模板数组   arr2可见数组   new_arr表格栏位数组
        for (let i = 0; i < arr1.length; i++) {
          if (arr2.indexOf(arr1[i].blockCode) !== -1) {
            // 排除不显示的栏位
            new_arr.push(arr1[i]);
            // if (!arr1[i].blockCode.match(/completionCertificateFile|satisfactionSurveyFile/)) {
            //   new_arr.push(arr1[i]);
            // }
          }
        }
        return new_arr;
      },
      async initData() {
        await this.getBlock()
        this.getData()
      },
      getBlock() {
        this.show = false
        return new Promise(resolve => {
          queryBySystemType({ systemType: this.listQuery.systemType === '' ? 'A' : this.listQuery.systemType }).then(res => {
            // 根据系统别获得模板栏位(有顺序关系)
            this.templateBlock = res.data
            // 根据字典设置栏位名称
            for (let i = 0; i < this.templateBlock.length; i++) {
              this.templateBlock[i].label = this.blockName[this.templateBlock[i].blockCode]
            }
            const data = {
              userId: this.$store.getters.info.id,
              systemType: this.listQuery.systemType === '' ? 'A' : this.listQuery.systemType
            }
            // 查询已设置的可显示的栏位
            queryDisplayBlock(data).then(resBlock => {
              this.displayBlock = resBlock.data
              this.displayBlockName = []
              // 获得可显示栏位的名称
              for (let i = 0; i < this.displayBlock.length; i++) {
                this.displayBlockName.push(this.displayBlock[i].blockCode)
              }
              this.checkAll = this.templateBlock.length === this.displayBlockName.length;
              const blockList = []
              this.blockList = []
              console.log(this.blockName)
              console.log(this.blockList)
              console.log(this.templateBlock)
              // 过滤出可以见的表格栏位
              if (this.displayBlock.length > 0) {
                this.blockList = this.sisExistArr(this.templateBlock, this.displayBlockName, blockList)
              } else {
                this.blockList = this.templateBlock
              }

              // 插入前固定栏位
              // this.blockList.unshift({
              //   blockCode: 'projectName'
              // })
              // 插入后固定栏位
              // 2021-08-16 start
              this.blockList.push({ blockCode: 'projectMeetingScheduleThis', label: this.$t('scheduleManager.progressList.projectMeetingScheduleThis') }) // '专案进度会议(本期)'
              this.blockList.push({ blockCode: 'projectMeetingScheduleNext', label: this.$t('scheduleManager.progressList.projectMeetingScheduleNext') }) // '专案进度会议(次期)'
              this.blockList.push({ blockCode: 'closingMeeting', label: this.$t('scheduleManager.progressList.closingMeeting') }) // '结案会议'
              this.blockList.push({ blockCode: 'projectMeetingScheduleRemarks', label: this.$t('scheduleManager.progressList.projectMeetingScheduleRemarks') }) // '专案进度会议备注'
              this.blockList.push({ blockCode: 'closingMeetingRemarks', label: this.$t('scheduleManager.progressList.closingMeetingRemarks') }) // '结案会议备注'
              // end
              this.blockList.push({ blockCode: 'paymentType', label: this.$t('scheduleManager.progressList.paymentType') }) // '客戶付款條件'
              this.blockList.push({ blockCode: 'requestFundsMoney', label: this.$t('scheduleManager.progressList.requestFundsMoney') }) // 請款金額
              this.blockList.push({ blockCode: 'capitalProjectionDate', label: this.$t('scheduleManager.progressList.capitalProjectionDate') }) // 未開發票預計收款日
              this.blockList.push({ blockCode: 'noticeInvoiceDate', label: this.$t('scheduleManager.progressList.noticeInvoiceDate') }) // 通知開發票日
              this.blockList.push({ blockCode: 'erpReceivablesNo', label: this.$t('scheduleManager.progressList.erpReceivablesNo') }) // ERP應收單號
              this.blockList.push({ blockCode: 'invoiceDate', label: this.$t('scheduleManager.progressList.invoiceDate') }) // ERP應收單號
              this.blockList.push({ blockCode: 'invoiceNo', label: this.$t('scheduleManager.progressList.invoiceNo') }) // 發票號碼
              this.blockList.push({ blockCode: 'invoiceMoney', label: this.$t('scheduleManager.progressList.invoiceMoney') }) // 發票金額

              this.blockList.push({ blockCode: 'expectedReceivablesDate', label: this.$t('scheduleManager.progressList.expectedReceivablesDate') }) // 預計收款日
              this.blockList.push({ blockCode: 'realityReceivablesDate', label: this.$t('scheduleManager.progressList.realityReceivablesDate') }) // 實際收款日
              this.blockList.push({ blockCode: 'receivablesMoney', label: this.$t('scheduleManager.progressList.receivablesMoney') }) // 收款金額
              this.blockList.push({ blockCode: 'deductionMoney', label: this.$t('scheduleManager.progressList.deductionMoney') }) // 扣款金額
              this.blockList.push({ blockCode: 'vendorName', label: this.$t('scheduleManager.progressList.vendorName') }) // 厂商简称
              this.blockList.push({ blockCode: 'vendorItem', label: this.$t('scheduleManager.progressList.vendorItem') }) // 廠商工項
              this.blockList.push({ blockCode: 'vendorOfferMoney', label: this.$t('scheduleManager.progressList.vendorOfferMoney') }) // 廠商報價金額
              this.blockList.push({ blockCode: 'vendorPoNo', label: this.$t('scheduleManager.progressList.vendorPoNo') }) // 廠商PO單號
              this.blockList.push({ blockCode: 'vendorPoMoney', label: this.$t('scheduleManager.progressList.vendorPoMoney') }) // 廠商PO金額

              this.blockList.push({ blockCode: 'vendorPayCondition', label: this.$t('scheduleManager.progressList.vendorPayCondition') }) // 廠商付款條件
              this.blockList.push({ blockCode: 'vendorPerformanceBondContent', label: this.$t('scheduleManager.progressList.vendorPerformanceBondContent') }) // 廠商履約保證金需求
              this.blockList.push({ blockCode: 'vendorPerformanceBondMoney', label: this.$t('scheduleManager.progressList.vendorPerformanceBondMoney') }) // 廠商履約保證金金額
              this.blockList.push({ blockCode: 'performanceBondExpireDate', label: this.$t('scheduleManager.progressList.performanceBondExpireDate') }) // 履約保證金到期日
              this.blockList.push({ blockCode: 'vendorExpectedFinishDate', label: this.$t('scheduleManager.progressList.vendorExpectedFinishDate') }) // 廠商預計完工日
              this.blockList.push({ blockCode: 'vendorRealityFinishDate', label: this.$t('scheduleManager.progressList.vendorRealityFinishDate') }) // 型錄
              this.blockList.push({ blockCode: 'catalogue', label: this.$t('scheduleManager.progressList.catalogue') }) //
              this.blockList.push({ blockCode: 'declareDate', label: this.$t('scheduleManager.progressList.declareDate') }) // 進口報關單日

              this.blockList.push({ blockCode: 'pictureData', label: this.$t('scheduleManager.progressList.pictureData') }) // 圖資
              this.blockList.push({ blockCode: 'operatingManual', label: this.$t('scheduleManager.progressList.operatingManual') }) // 操作手冊
              this.blockList.push({ blockCode: 'factoryCertificate', label: this.$t('scheduleManager.progressList.factoryCertificate') }) // 出廠證明
              this.blockList.push({ blockCode: 'testReport', label: this.$t('scheduleManager.progressList.testReport') }) //  廠測報告
              this.blockList.push({ blockCode: 'signFileDate', label: this.$t('scheduleManager.progressList.signFileDate') }) // 設備/材料簽收單日
              this.blockList.push({ blockCode: 'signersignatory', label: this.$t('scheduleManager.progressList.signersignatory') }) // 簽收人
              this.blockList.push({ blockCode: 'warrantyFileDate', label: this.$t('scheduleManager.progressList.warrantyFileDate') }) // 保固文件交付日
              this.blockList.push({ blockCode: 'otherFileName', label: this.$t('scheduleManager.progressList.otherFileName') }) // 其他文件名稱
              this.blockList.push({ blockCode: 'otherFileSendDate', label: this.$t('scheduleManager.progressList.otherFileSendDate') }) // 其他文件交付日

              this.blockList.push({ blockCode: 'sendCheckFileDate', label: this.$t('scheduleManager.progressList.sendCheckFileDate') }) // 驗收文件交付日
              this.blockList.push({ blockCode: 'vendorAcceptanceDate', label: this.$t('scheduleManager.progressList.vendorAcceptanceDate') }) // 廠商驗收日
              this.blockList.push({ blockCode: 'vendorWarrantyType', label: this.$t('scheduleManager.progressList.vendorWarrantyType') }) // 廠商保固金類型
              this.blockList.push({ blockCode: 'vendorWarrantyStartDate', label: this.$t('scheduleManager.progressList.vendorWarrantyStartDate') }) // 廠商保固開始日
              this.blockList.push({ blockCode: 'vendorWarrantyEndDate', label: this.$t('scheduleManager.progressList.vendorWarrantyEndDate') }) // 廠商保固截止日
              this.blockList.push({ blockCode: 'vendorWarrantyReturnDate', label: this.$t('scheduleManager.progressList.vendorWarrantyReturnDate') }) // 廠商保固金退回日
              this.blockList.push({ blockCode: 'vendorAppraiseDate', label: this.$t('scheduleManager.progressList.vendorAppraiseDate') }) // 廠商評鑑表日

              this.blockList.push({ blockCode: 'expectedPaymentMoney', label: this.$t('scheduleManager.progressList.expectedPaymentMoney') }) // 預計付款金額
              this.blockList.push({ blockCode: 'capitalProjectionPaymentDate', label: this.$t('scheduleManager.progressList.capitalProjectionPaymentDate') }) // 未收發票預計付款日(資金預估)
              this.blockList.push({ blockCode: 'vendorNoticeInvoiceDate', label: this.$t('scheduleManager.progressList.vendorNoticeInvoiceDate') }) // 通知廠商開發票日
              this.blockList.push({ blockCode: 'erpPayableNo', label: this.$t('scheduleManager.progressList.erpPayableNo') }) // ERP應付單號
              this.blockList.push({ blockCode: 'vendorInvoiceDate', label: this.$t('scheduleManager.progressList.vendorInvoiceDate') }) // 廠商發票日 vendorInvoiceDates
              this.blockList.push({ blockCode: 'vendorInvoiceNo', label: this.$t('scheduleManager.progressList.vendorInvoiceNo') }) // 廠商發票號碼
              this.blockList.push({ blockCode: 'vendorInvoiceMoney', label: this.$t('scheduleManager.progressList.vendorInvoiceMoney') }) // 廠商發票金額
              this.blockList.push({ blockCode: 'expectedPaymentDate', label: this.$t('scheduleManager.progressList.expectedPaymentDate') }) // 預計付款日
              this.blockList.push({ blockCode: 'realityPaymentDate', label: this.$t('scheduleManager.progressList.realityPaymentDate') }) // 實際付款日
              this.blockList.push({ blockCode: 'paymentMoney', label: this.$t('scheduleManager.progressList.paymentMoney') }) // 付款金額
              this.blockList.push({ blockCode: 'paymentRemark', label: this.$t('scheduleManager.progressList.paymentRemark') }) // 付款備註

              this.setTableSum()
              resolve();
            })
          })
        })
      },
      getData() {
        this.show = false
        // 查询列表的数据并求出subtotal
        const query = this.listQuery
        queryList(query).then(res => {
          if (res.status !== 200) {
            this.$notify({
              title: this.$t('scheduleManager.progressList.getFail'),
              message: res.message,
              type: 'warning'
            });
          } else {
            this.list = res.data.rows
            this.total = res.data.total;
            this.subtotal = res.data.subtotal

            this.list.forEach((row, i) => {
              // 系统别
              this.list[i].systemType = this.listMapAll.systemType[this.list[i].systemType];
              // 国别
              this.list[i].country = this.listMapAll.country[this.list[i].country] ? this.listMapAll.country[this.list[i].country] : this.list[i].country;
              // 公司别
              this.list[i].companyType = this.listMapAll.company[this.list[i].companyType];
              // 專案狀態
              this.list[i].projectStatus = this.listMapAll.projectStatus[this.list[i].projectStatus];
              // 付款狀態
              this.list[i].payStatus = this.listMapAll.projectName[this.list[i].payStatus];
              // 可否請款
              this.list[i].isRequestFunds = this.listMapAll.payment[this.list[i].isRequestFunds];
              // 區別
              this.list[i].difference = this.listMapAll.difference[this.list[i].difference];
              // 月份
              this.list[i].contractMonth = this.listMapAll.month[this.list[i].contractMonth];
              // 年度
              this.list[i].projectYear = this.listMapAll.year[this.list[i].projectYear];
              this.list[i].offerYear = this.listMapAll.year[this.list[i].offerYear];
              this.list[i].executeYear = this.listMapAll.year[this.list[i].executeYear];
              this.list[i].customerYear = this.listMapAll.year[this.list[i].customerYear];
              // 工程類別
              this.list[i].epcType = this.listMapAll.epcType[this.list[i].epcType];
              // 季別
              this.list[i].contractQuarter = this.listMapAll.quarter[this.list[i].contractQuarter];
              // 幣別
              this.list[i].currencyType = this.listMapAll.currencyType[this.list[i].currencyType];
              // 履約保證金需求
              // this.list[i].performanceBondContent = this.listMapAll.performanceBondContent[this.list[i].performanceBondContent];
              if (this.list[i].performanceBondContent) {
                const obj = Object.assign(this.list[i].performanceBondContent)
                const arr = obj.split(',');
                this.list[i].performanceBondContent = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.performanceBondContent[a] ? this.listMapAll.performanceBondContent[a] : ''
                    if (value) {
                      this.list[i].performanceBondContent = value + ',' + this.list[i].performanceBondContent
                    } else if (a) {
                      this.list[i].performanceBondContent = a + ',' + this.list[i].performanceBondContent
                    }
                  }
                })
                this.list[i].performanceBondContent = this.list[i].performanceBondContent.substring(0, this.list[i].performanceBondContent.length - 1)
              }



              // 保險需求(Y/N)
              this.list[i].isInsure = this.listMapAll.NorY[this.list[i].isInsure];
              // 客戶保固金類型
              // this.list[i].warrantyMoneyType = this.listMapAll.warrantyMoneyType[this.list[i].warrantyMoneyType];
              if (this.list[i].warrantyMoneyType) {
                const obj = Object.assign(this.list[i].warrantyMoneyType)
                const arr = obj.split(',');
                this.list[i].warrantyMoneyType = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.warrantyMoneyType[a] ? this.listMapAll.warrantyMoneyType[a] : ''
                    if (value) {
                      this.list[i].warrantyMoneyType = value + ',' + this.list[i].warrantyMoneyType
                    } else if (a) {
                      this.list[i].warrantyMoneyType = a + ',' + this.list[i].warrantyMoneyType
                    }
                  }
                })
                this.list[i].warrantyMoneyType = this.list[i].warrantyMoneyType.substring(0, this.list[i].warrantyMoneyType.length - 1)
              }

              // 客户付款条件
              // this.list[i].paymentType = this.listMapAll.paymentType[this.list[i].paymentType];
              if (this.list[i].paymentType) {
                const obj = Object.assign(this.list[i].paymentType)
                const arr = obj.split(',');
                this.list[i].paymentType = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.paymentType[a] ? this.listMapAll.paymentType[a] : ''
                    if (value) {
                      this.list[i].paymentType = value + ',' + this.list[i].paymentType
                    } else if (a) {
                      this.list[i].paymentType = a + ',' + this.list[i].paymentType
                    }
                  }
                })
                this.list[i].paymentType = this.list[i].paymentType.substring(0, this.list[i].paymentType.length - 1)
              }
              // 廠商折數
              this.list[i].vendorDiscount = this.list[i].vendorDiscount ? this.list[i].vendorDiscount + '%' : '';

              // 厂商付款条件
              if (this.list[i].vendorPayCondition) {
                const obj = Object.assign(this.list[i].vendorPayCondition)
                const arr = obj.split(',');
                this.list[i].vendorPayCondition = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.paymentType[a] ? this.listMapAll.paymentType[a] : ''
                    if (value) {
                      this.list[i].vendorPayCondition = value + ',' + this.list[i].vendorPayCondition
                    } else if (a) {
                      this.list[i].vendorPayCondition = a + ',' + this.list[i].vendorPayCondition
                    }
                  }
                })
                this.list[i].vendorPayCondition = this.list[i].vendorPayCondition.substring(0, this.list[i].vendorPayCondition.length - 1)
              }
              // 厂商履约保证金需求
              if (this.list[i].vendorPerformanceBondContent) {
                const obj = Object.assign(this.list[i].vendorPerformanceBondContent)
                const arr = obj.split(',');
                this.list[i].vendorPerformanceBondContent = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.vendorPerformanceBondContent[a] ? this.listMapAll.vendorPerformanceBondContent[a] : ''
                    if (value) {
                      this.list[i].vendorPerformanceBondContent = value + ',' + this.list[i].vendorPerformanceBondContent
                    } else if (a) {
                      this.list[i].vendorPerformanceBondContent = a + ',' + this.list[i].vendorPerformanceBondContent
                    }
                  }
                })
                this.list[i].vendorPerformanceBondContent = this.list[i].vendorPerformanceBondContent.substring(0, this.list[i].vendorPerformanceBondContent.length - 1)
              }
              // 厂商保固金类型
              if (this.list[i].vendorWarrantyType) {
                const obj = Object.assign(this.list[i].vendorWarrantyType)
                const arr = obj.split(',');
                this.list[i].vendorWarrantyType = ''
                arr.forEach(a => {
                  if (a) {
                    const value = this.listMapAll.vendorWarrantyType[a] ? this.listMapAll.vendorWarrantyType[a] : ''
                    if (value) {
                      this.list[i].vendorWarrantyType = value + ',' + this.list[i].vendorWarrantyType
                    } else if (a) {
                      this.list[i].vendorWarrantyType = a + ',' + this.list[i].vendorWarrantyType
                    }
                  }
                })
                this.list[i].vendorWarrantyType = this.list[i].vendorWarrantyType.substring(0, this.list[i].vendorWarrantyType.length - 1)
              }
            })

            // 合计
            this.setTableSum()
            this.show = true
          }
        })
      },
      // 删除
      handleDelete() {
        let clientName = ''
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('tips.fail'), // '失败',
            message: this.$t('specialApplication.maintenance.pleaseSelectOne'), // 请选择一条记录
            type: 'warning'
          });
          return false
        }
        this.selectionList.forEach((row, i) => {
          clientName += clientName !== '' ? '、' + this.selectionList[i].systemNo : this.selectionList[i].systemNo
        })

       
      this.$confirm('此操作將永久刪除系統編號為：' + clientName + this.$t('worksTargetEdit.notify.message8') + this.selectionList.length + this.$t('worksTargetEdit.notify.message6') + this.$t('worksTargetEdit.notify.message7'), this.$t('worksTargetEdit.notify.message5'),{type:'warning'}).then(()=>{
          const arr = []; // 存放已修改的
          this.selectionList.forEach(item => {
             arr.push(item);
          })
          projectProgressDelete(arr).then(res => {
            this.$notify({
              title: res.status === 200 ? this.$t('tips.success') : this.$t('tips.fail'), // '成功' : '失败',
              message: res.data,
              type: res.status === 200 ? 'success' : 'warning'
            });
            this.getData();
          });
      }).catch(() => {
        this.$message({ type: 'info', message: this.$t('worksTargetEdit.message.message2') });
      });
      },
      setTableSum() {
        if (this.subtotal) {
          for (let i = 0; i < this.blockList.length; i++) {
            if (this.subtotal[this.blockList[i].blockCode] || this.subtotal[this.blockList[i].blockCode] === 0) {
              this.blockList[i].sum = String(this.subtotal[this.blockList[i].blockCode] + '').replace(/\d{1,3}(?=(\d{3})+(\.|$))/g, '$&,').toString()
            }
          }
        } else {
          for (let i = 0; i < this.blockList.length; i++) {
            this.blockList[i].sum = ''
          }
        }
        this.show = true
      }
    },
    beforeDestroy() {
      window.sessionStorage.setItem('progressListQuery', JSON.stringify(this.listQuery))
    }
  };
</script>
<style scoped lang="scss">

  /deep/ .el-select__input{
    flex-grow: 1 !important;
    width: 138px !important;
    max-width: 138px !important;
  }

  .wid{
    width:110px;
  }

  .el-checkbox{
    min-width: 167px;
  }

  .el-checkbox+ .el-checkbox {
     margin-left: 0;
  }

</style>
